<?php $this->headScript()->appendFile($this->JS_PATH . "story.js"); ?>
<script src="https://cdn.firebase.com/v0/firebase.js"></script>
<?php
$FIREBASE_BASE_URL = "https://aaronprojects.firebaseio.com/";
$PROJECT_ID = 1;
?>
<script>
        var FIRE_BASE_APP_LINK = "<?php echo $FIREBASE_BASE_URL;?>";
        var PROJECT_ID = <?php echo $PROJECT_ID; ?>;
</script>
<div id="story-listing"></div>
<?php echo $this->flashmessages(); ?>
<?php if (count($this->errorMessage) > 0): ?>
    <div class="alert alert-error">
        <?php foreach ($this->errorMessage as $erroValue): ?>
            <div class="text-left">
                <i class="icon-remove-sign"></i>
                <?php echo $erroValue; ?>
            </div>

        <?php endforeach; ?>
    </div>
<?php endif; ?><div id="pad-wrapper">
    <div class="row pagelist-header">
        <h3>Story Listing</h3>
    </div>
    <div class="table-products">
        <form action="" method="post" id="storylistingfrm">

            <div class="row-fluid ">
                <div class="pull-right">
                    <a class="btn-flat new-product"
                       href="<?php echo $this->url(array("module" => "default", "controller" => "story", "action" => "form"), null, TRUE); ?>"
                       >+ Add New</a>                        
                </div>
            </div>

            <div class="row">
                <?php if (count($this->storysData) > 0): ?> 
                    <div class="delete_All">    
                        <input type="submit" accesskey="s" value="Delete All" name="multiaction"  id="multiaction" class="btn-flat danger"/>      
                    <?php else: ?>
                        &nbsp;
                    <?php endif; ?>
                </div> <table class="table table-hover">
                    <thead>
                        <tr>
                            <th><input id="selectall" type="checkbox"/></th>                        
                            <th class="col-md-3">
                                <a href="<?php echo $this->url(array("controller" => "story", "action" => "list", "field" => "proj_title", "sort" => "asc"), "default", false); ?>">
                                    <img src="<?php echo $this->IMAGE_PATH; ?>datatables/sort_asc.png"  alt="Ascending" title="Ascending" class="sort_asc" />
                                </a>
                                Project Name
                                <a href="<?php echo $this->url(array("controller" => "story", "action" => "list", "field" => "proj_title", "sort" => "desc"), "default", false); ?>">
                                    <img src="<?php echo $this->IMAGE_PATH; ?>datatables/sort_desc.png"  alt="Descending" title="Descending" class="sort_desc"  />
                                </a>

                            </th><th class="col-md-3">
                                <a href="<?php echo $this->url(array("controller" => "story", "action" => "list", "field" => "st_note", "sort" => "asc"), "default", false); ?>">
                                    <img src="<?php echo $this->IMAGE_PATH; ?>datatables/sort_asc.png"  alt="Ascending" title="Ascending" class="sort_asc" />
                                </a>
                                Note
                                <a href="<?php echo $this->url(array("controller" => "story", "action" => "list", "field" => "st_note", "sort" => "desc"), "default", false); ?>">
                                    <img src="<?php echo $this->IMAGE_PATH; ?>datatables/sort_desc.png"  alt="Descending" title="Descending" class="sort_desc"  />
                                </a>

                            </th><th class="col-md-3">
                                <a href="<?php echo $this->url(array("controller" => "story", "action" => "list", "field" => "st_status", "sort" => "asc"), "default", false); ?>">
                                    <img src="<?php echo $this->IMAGE_PATH; ?>datatables/sort_asc.png"  alt="Ascending" title="Ascending" class="sort_asc" />
                                </a>
                                Status
                                <a href="<?php echo $this->url(array("controller" => "story", "action" => "list", "field" => "st_status", "sort" => "desc"), "default", false); ?>">
                                    <img src="<?php echo $this->IMAGE_PATH; ?>datatables/sort_desc.png"  alt="Descending" title="Descending" class="sort_desc"  />
                                </a>
                                <span class="cls_action"> Action</span>
                            </th>  </tr>
                    </thead>
                    <tbody>
                        <?php if (count($this->storysData) > 0): ?>
                            <?php $counter = 0; ?>
                            <?php foreach ($this->storysData as $key => $value) : ?>
                                <!-- row -->
                                <tr <?php if ($counter == 0): ?>class="first"<?php endif; ?>>
                                    <td><input type="checkbox" class="content-checkbox" name="multicheck[]" value="<?php echo $value["st_id"]; ?>"/>
                                    </td> <td> 
                                        <a href="<?php echo $this->url(array("module" => "default", "controller" => "story", "action" => "form", "st_id" => $value["st_id"]), null, true); ?>">
                                            <?php echo $value["proj_title"]; ?>
                                        </a>

                                    </td>
                                    <td> 
                                        <?php echo substr($value["st_note"],0,100); ?>
                                    </td>
                                    <td> 

                                        <?php if ($value["st_status"] == 1): ?>
                                            <span class="label label-success">Active</span>
                                        <?php else:
                                            ?>
                                            <span class="label label-info">InActive</span>
                                        <?php
                                        endif;
                                        ?>
                                            <!--<span class="label label-info"> Update</span>-->
                                            <input type="hidden" name="proj_id" id="proj_id" value="<?php echo $value["st_proj_id"]; ?>"/>
                                            <input type="hidden" name="login_name" id="login_name" value="<?php echo $value["u_name"]; ?>"/>
                                            <input type="hidden" name="story_note" id="story_note" value="<?php echo $value["st_note"]; ?>"/>
                                            <input class="label-info storycls storypush" story_id="<?php echo $value["st_id"]; ?>" proj_id="<?php echo $value["st_proj_id"]; ?>" login_name="<?php echo $value["u_name"]; ?>" story_note="<?php echo $value["st_note"]; ?>"  type="button" name=""  value="Update">
                                            
                                            <input class="label-info storycls timepush" story_id="<?php echo $value["st_id"]; ?>" proj_id="<?php echo $value["st_proj_id"]; ?>" login_name="<?php echo $value["u_name"]; ?>" story_note="<?php echo $value["st_note"]; ?>" time_slot ="<?php echo $value["st_time_slot"]; ?>"  type="button" name=""  value="Update Time">
                                             
                                        <ul class="actions">
                                            <li>
                                                <a title="Edit" href="<?php echo $this->url(array("module" => "default", "controller" => "story", "action" => "form", "st_id" => $value["st_id"]), null, true); ?>">
                                                    <i class="table-edit"></i>
                                                </a>
                                            </li>
                                            <li >
                                                <a title="View" class="view_anchr" href="<?php echo $this->url(array("module" => "default", "controller" => "story", "action" => "view", "st_id" => $value["st_id"]), null, true); ?>">
                                                    <i class="icon-eye-open"></i>
                                                </a>
                                            </li>
                                            <li class="last">
                                                <a title="Delete" href="<?php echo $this->url(array("module" => "default", "controller" => "story", "action" => "delete", "st_id" => $value["st_id"]), null, true); ?>">
                                                    <i class="table-delete"></i>
                                                </a>
                                            </li>
                                        </ul>
                                    </td>

                                </tr>
                                <?php $counter++; ?>
                            <?php endforeach; ?>
                        <?php else: ?>
                            <tr class="row2" >
                                <td>&nbsp;</td>
                                <td colspan="8"> No Record Found</td>
                            </tr>
                        <?php endif; ?>
                    </tbody>
                </table></div>
            <?php
            if (count($this->storysData) > 0):
                echo $this->paginator->displayPages();
            endif;
            ?>
        </form>
    </div>
</div>